package com.atguigu.gulimall.mudan.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.atguigu.gulimall.mudan.entity.ClassEntity;
import com.atguigu.gulimall.mudan.service.ClassService;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;



/**
 * 
 *
 * @author yashu
 * @email 2377311752@qq.com
 * @date 2021-06-17 20:31:18
 */
@RestController
@RequestMapping("mudan/class")
public class ClassController {
    @Autowired
    private ClassService classService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("mudan:class:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = classService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{peonyClassId}")
    //@RequiresPermissions("mudan:class:info")
    public R info(@PathVariable("peonyClassId") Integer peonyClassId){
		ClassEntity class1 = classService.getById(peonyClassId);

        return R.ok().put("class", class1);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("mudan:class:save")
    public R save(@RequestBody ClassEntity class1){
		classService.save(class1);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("mudan:class:update")
    public R update(@RequestBody ClassEntity class1){
		classService.updateById(class1);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("mudan:class:delete")
    public R delete(@RequestBody Integer[] peonyClassIds){
		classService.removeByIds(Arrays.asList(peonyClassIds));

        return R.ok();
    }

}
